<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.8.0">
    

    

    



    <meta charset="utf-8">
    
    
    
    
    <title>前端小纠结--集成gitflow和standard-version使用 | 个人博客 | 一个coder的成长记录</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#3F51B5">
    
    
    <meta name="keywords" content="fe,gitflow,standard-version">
    <meta name="description" content="前端小纠结–集成gitflow和standard-version使用 请看上一篇前端小纠结–约定式提交和自动生成changelog  git flow工作流对比 Git工作流指南  git flow 介绍 git flow源自这篇文章a-successful-git-branching-model，大神！！！。 关于git flow的使用，请看以下链接，非常多的文章，写的非常好。  如何正确的使用">
<meta name="keywords" content="fe,gitflow,standard-version">
<meta property="og:type" content="article">
<meta property="og:title" content="前端小纠结--集成gitflow和standard-version使用">
<meta property="og:url" content="https://betgar.github.io/2019/05/21/frontend-little-tangle-integrate-git-flow-and-standard-version/index.html">
<meta property="og:site_name" content="个人博客">
<meta property="og:description" content="前端小纠结–集成gitflow和standard-version使用 请看上一篇前端小纠结–约定式提交和自动生成changelog  git flow工作流对比 Git工作流指南  git flow 介绍 git flow源自这篇文章a-successful-git-branching-model，大神！！！。 关于git flow的使用，请看以下链接，非常多的文章，写的非常好。  如何正确的使用">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521102909-git-flow-nvie.png">
<meta property="og:image" content="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521103213-git-workflow-release-cycle-1historical.png">
<meta property="og:image" content="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521103229-git-workflow-release-cycle-2feature.png">
<meta property="og:image" content="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521105032-feature-branch.png">
<meta property="og:image" content="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521103240-git-workflow-release-cycle-3release.png">
<meta property="og:image" content="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521105209-minor-release.png">
<meta property="og:image" content="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521105223-major-release.png">
<meta property="og:image" content="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521103251-git-workflow-release-cycle-4maintenance.png">
<meta property="og:image" content="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521105905-hotfix-branch.png">
<meta property="og:image" content="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521111135-support-hotfix.png">
<meta property="og:image" content="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521111047-support-minor.png">
<meta property="og:image" content="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521140451-sourcetree-git-flow.jpg">
<meta property="og:updated_time" content="2019-06-14T08:29:44.250Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="前端小纠结--集成gitflow和standard-version使用">
<meta name="twitter:description" content="前端小纠结–集成gitflow和standard-version使用 请看上一篇前端小纠结–约定式提交和自动生成changelog  git flow工作流对比 Git工作流指南  git flow 介绍 git flow源自这篇文章a-successful-git-branching-model，大神！！！。 关于git flow的使用，请看以下链接，非常多的文章，写的非常好。  如何正确的使用">
<meta name="twitter:image" content="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521102909-git-flow-nvie.png">
    
        <link rel="alternate" type="application/atom+xml" title="个人博客" href="/atom.xml">
    
    <link rel="shortcut icon" href="/favicon.ico">
    <link rel="stylesheet" href="//unpkg.com/hexo-theme-material-indigo@latest/css/style.css">
    <script>window.lazyScripts=[]</script>

    <!-- custom head -->
    

</head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu" class="hide">
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap" style="background-image:url(/img/brand.jpg)">
      <div class="brand">
        <a href="/" class="avatar waves-effect waves-circle waves-light">
          <img src="/img/avatar.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">俊男</h5>
          <a href="mailto:betgar@163.com" title="betgar@163.com" class="mail">betgar@163.com</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/">
                <i class="icon icon-lg icon-home"></i>
                Home
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/archives">
                <i class="icon icon-lg icon-archives"></i>
                Archives
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/tags">
                <i class="icon icon-lg icon-tags"></i>
                Tags
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/categories">
                <i class="icon icon-lg icon-th-list"></i>
                Categories
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://github.com/betgar" target="_blank">
                <i class="icon icon-lg icon-github"></i>
                Github
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://weibo.com/u/2296734915" target="_blank">
                <i class="icon icon-lg icon-weibo"></i>
                Weibo
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/about">
                <i class="icon icon-lg icon-link"></i>
                About
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">前端小纠结--集成gitflow和standard-version使用</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">前端小纠结--集成gitflow和standard-version使用</h1>
        <h5 class="subtitle">
            
                <time datetime="2019-05-21T00:00:00.000Z" itemprop="datePublished" class="page-time">
  2019-05-21
</time>


	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/gitflow/">gitflow</a><ul class="article-category-list-child"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/gitflow/fe/">fe</a></li></ul></li></ul>

            
        </h5>
    </div>

    


</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap post-toc-shrink" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#前端小纠结–集成gitflow和standard-version使用"><span class="post-toc-number">1.</span> <span class="post-toc-text">前端小纠结–集成gitflow和standard-version使用</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#git-flow工作流对比"><span class="post-toc-number">1.0.1.</span> <span class="post-toc-text">git flow工作流对比</span></a></li></ol></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#git-flow-介绍"><span class="post-toc-number">1.1.</span> <span class="post-toc-text">git flow 介绍</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#git-flow常用的分支"><span class="post-toc-number">1.1.1.</span> <span class="post-toc-text">git flow常用的分支</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#git-Flow如何工作"><span class="post-toc-number">1.1.2.</span> <span class="post-toc-text">git Flow如何工作</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#feature分支"><span class="post-toc-number">1.1.2.1.</span> <span class="post-toc-text">feature分支</span></a></li><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#release分支"><span class="post-toc-number">1.1.2.2.</span> <span class="post-toc-text">release分支</span></a></li><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#hotfix分支"><span class="post-toc-number">1.1.2.3.</span> <span class="post-toc-text">hotfix分支</span></a></li><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#support分支"><span class="post-toc-number">1.1.2.4.</span> <span class="post-toc-text">support分支</span></a></li><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#多版本hotfix修复"><span class="post-toc-number">1.1.2.5.</span> <span class="post-toc-text">多版本hotfix修复</span></a></li><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#多版本的release"><span class="post-toc-number">1.1.2.6.</span> <span class="post-toc-text">多版本的release</span></a></li></ol></li></ol></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#git-flow工具的使用"><span class="post-toc-number">1.2.</span> <span class="post-toc-text">git flow工具的使用</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#git-flow和standard-version搭配使用"><span class="post-toc-number">1.3.</span> <span class="post-toc-text">git flow和standard-version搭配使用</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#git-flow流程中standard-version使用"><span class="post-toc-number">1.3.1.</span> <span class="post-toc-text">git flow流程中standard-version使用</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#git-flow和standard-version冲突的tag功能"><span class="post-toc-number">1.3.2.</span> <span class="post-toc-text">git flow和standard-version冲突的tag功能</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#standard-version运行时机"><span class="post-toc-number">1.3.3.</span> <span class="post-toc-text">standard-version运行时机</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#standard-version在git-flow不同流程阶段注意的问题"><span class="post-toc-number">1.3.4.</span> <span class="post-toc-text">standard-version在git flow不同流程阶段注意的问题</span></a></li></ol></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#建议"><span class="post-toc-number">1.4.</span> <span class="post-toc-text">建议</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#参考"><span class="post-toc-number">1.5.</span> <span class="post-toc-text">参考</span></a></li></ol>
        </nav>
    </aside>


<article id="post-frontend-little-tangle-integrate-git-flow-and-standard-version" class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">前端小纠结--集成gitflow和standard-version使用</h1>
        <div class="post-meta">
            <time class="post-time" title="2019-05-21 08:00:00" datetime="2019-05-21T00:00:00.000Z" itemprop="datePublished">2019-05-21</time>

            
	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/gitflow/">gitflow</a><ul class="article-category-list-child"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/gitflow/fe/">fe</a></li></ul></li></ul>



            
<span id="busuanzi_container_page_pv" title="文章总阅读量" style="display:none">
    <i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>


        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <h1 id="前端小纠结–集成gitflow和standard-version使用"><a href="#前端小纠结–集成gitflow和standard-version使用" class="headerlink" title="前端小纠结–集成gitflow和standard-version使用"></a>前端小纠结–集成<code>gitflow</code>和<code>standard-version</code>使用</h1><blockquote>
<p>请看上一篇<a href="https://betgar.github.io/2019/05/20/frontend-little-tangle-conventional-commit-and-generate-changelog/">前端小纠结–约定式提交和自动生成<code>changelog</code></a></p>
</blockquote>
<h3 id="git-flow工作流对比"><a href="#git-flow工作流对比" class="headerlink" title="git flow工作流对比"></a><code>git flow</code>工作流对比</h3><blockquote>
<p><a href="http://blog.jobbole.com/76843/" target="_blank" rel="noopener">Git工作流指南</a></p>
</blockquote>
<h2 id="git-flow-介绍"><a href="#git-flow-介绍" class="headerlink" title="git flow 介绍"></a><code>git flow 介绍</code></h2><blockquote>
<p><code>git flow</code>源自这篇文章<a href="https://nvie.com/posts/a-successful-git-branching-model/" target="_blank" rel="noopener">a-successful-git-branching-model</a>，大神！！！。</p>
<p>关于<code>git flow</code>的使用，请看以下链接，非常多的文章，写的非常好。</p>
</blockquote>
<p><a href="http://www.cnblogs.com/cnblogsfans/p/5075073.html" target="_blank" rel="noopener">如何正确的使用git flow</a></p>
<p><a href="https://danielkummer.github.io/git-flow-cheatsheet/index.zh_CN.html" target="_blank" rel="noopener">git-flow 备忘清单</a></p>
<blockquote>
<p>git-branching-model 如图</p>
</blockquote>
<figure class="image-bubble">
                <div class="img-lightbox">
                    <div class="overlay"></div>
                    <img src="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521102909-git-flow-nvie.png" alt="git-flow-nvie" title>
                </div>
                <div class="image-caption">git-flow-nvie</div>
            </figure>
<h3 id="git-flow常用的分支"><a href="#git-flow常用的分支" class="headerlink" title="git flow常用的分支"></a><code>git flow</code>常用的分支</h3><blockquote>
<p>以下部分内容来自<a href="http://www.cnblogs.com/cnblogsfans/p/5075073.html" target="_blank" rel="noopener">如何正确的使用git flow</a>博客和<a href="https://gitversion.readthedocs.io/en/latest/git-branching-strategies/gitflow-examples/" target="_blank" rel="noopener">gitflow-examples</a></p>
</blockquote>
<ul>
<li><code>develop</code> :  这个分支是我们是我们的主开发分支，包含所有要发布到下一个Release的代码，这个主要合并与其他分支，比如Feature分支</li>
<li><code>release/*</code> : 当你需要一个发布一个新Release的时候，我们基于Develop分支创建一个Release分支，完成Release后，我们合并到Master和Develop分支</li>
<li><code>master</code> : 也就是我们经常使用的Master分支，这个分支最近发布到生产环境的代码，最近发布的Release， 这个分支只能从其他分支合并，不能在这个分支直接修改</li>
<li><code>hotfix/*</code> 当我们在生产环境(master)发现新的Bug时候，我们需要创建一个Hotfix, 完成Hotfix后，我们合并回Master和Develop分支，所以Hotfix的改动会进入下一个Release</li>
<li>feature/* : 这个分支主要是用来开发一个新的功能，一旦开发完成，我们合并回Develop分支进入下一个Release</li>
</ul>
<h3 id="git-Flow如何工作"><a href="#git-Flow如何工作" class="headerlink" title="git Flow如何工作"></a>git Flow如何工作</h3><blockquote>
<p>所有在Master分支上的Commit应该Tag</p>
</blockquote>
<figure class="image-bubble">
                <div class="img-lightbox">
                    <div class="overlay"></div>
                    <img src="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521103213-git-workflow-release-cycle-1historical.png" alt="git-workflow-release-cycle-1historical" title>
                </div>
                <div class="image-caption">git-workflow-release-cycle-1historical</div>
            </figure>
<h4 id="feature分支"><a href="#feature分支" class="headerlink" title="feature分支"></a><code>feature</code>分支</h4><blockquote>
<p>分支名 feature/*</p>
<p>Feature分支做完后，必须合并回Develop分支, 合并完分支后一般会删点这个Feature分支</p>
</blockquote>
<figure class="image-bubble">
                <div class="img-lightbox">
                    <div class="overlay"></div>
                    <img src="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521103229-git-workflow-release-cycle-2feature.png" alt="git-workflow-release-cycle-2feature" title>
                </div>
                <div class="image-caption">git-workflow-release-cycle-2feature</div>
            </figure>
<figure class="image-bubble">
                <div class="img-lightbox">
                    <div class="overlay"></div>
                    <img src="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521105032-feature-branch.png" alt="feature-branch" title>
                </div>
                <div class="image-caption">feature-branch</div>
            </figure>
<h4 id="release分支"><a href="#release分支" class="headerlink" title="release分支"></a><code>release</code>分支</h4><blockquote>
<p>分支名 release/*</p>
<p>Release分支基于Develop分支创建，打完Release分之后，我们可以在这个Release分支上测试，修改Bug等。同时，其它开发人员可以基于开发新的Feature (记住：<strong>一旦打了Release分支之后不要从Develop分支上合并新的改动到Release分支</strong>)</p>
<p>发布Release分支时，合并Release到Master和Develop， 同时在Master分支上打个Tag记住Release版本号，然后可以删除Release分支了。</p>
</blockquote>
<figure class="image-bubble">
                <div class="img-lightbox">
                    <div class="overlay"></div>
                    <img src="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521103240-git-workflow-release-cycle-3release.png" alt="git-workflow-release-cycle-3release" title>
                </div>
                <div class="image-caption">git-workflow-release-cycle-3release</div>
            </figure>
<blockquote>
<p>minor版本发布</p>
</blockquote>
<figure class="image-bubble">
                <div class="img-lightbox">
                    <div class="overlay"></div>
                    <img src="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521105209-minor-release.png" alt="minor-release" title>
                </div>
                <div class="image-caption">minor-release</div>
            </figure>
<blockquote>
<p>major版本发布</p>
</blockquote>
<figure class="image-bubble">
                <div class="img-lightbox">
                    <div class="overlay"></div>
                    <img src="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521105223-major-release.png" alt="major-release" title>
                </div>
                <div class="image-caption">major-release</div>
            </figure>
<h4 id="hotfix分支"><a href="#hotfix分支" class="headerlink" title="hotfix分支"></a><code>hotfix</code>分支</h4><blockquote>
<p>分支名 hotfix/*</p>
<p>hotfix分支基于Master分支创建，开发完后需要合并回Master和Develop分支，同时在Master上打一个tag</p>
</blockquote>
<figure class="image-bubble">
                <div class="img-lightbox">
                    <div class="overlay"></div>
                    <img src="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521103251-git-workflow-release-cycle-4maintenance.png" alt="git-workflow-release-cycle-4maintenance" title>
                </div>
                <div class="image-caption">git-workflow-release-cycle-4maintenance</div>
            </figure>
<blockquote>
<p>hotfix修复分支</p>
</blockquote>
<figure class="image-bubble">
                <div class="img-lightbox">
                    <div class="overlay"></div>
                    <img src="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521105905-hotfix-branch.png" alt="hotfix-branch" title>
                </div>
                <div class="image-caption">hotfix-branch</div>
            </figure>
<h4 id="support分支"><a href="#support分支" class="headerlink" title="support分支"></a><code>support</code>分支</h4><blockquote>
<p>GitFlow没有真正涵盖<code>support</code>分支，如果需要同时维护多个主要版本，则必不可少。 您也可以使用<code>support</code>分支来支持<code>minor</code>版本。 如果您只是支持<code>major</code>，命名<code>support/&lt;major&gt;.x</code>，minor版本为<code>support/&lt;major&gt;.&lt;minor&gt;.x</code></p>
</blockquote>
<h4 id="多版本hotfix修复"><a href="#多版本hotfix修复" class="headerlink" title="多版本hotfix修复"></a>多版本hotfix修复</h4><figure class="image-bubble">
                <div class="img-lightbox">
                    <div class="overlay"></div>
                    <img src="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521111135-support-hotfix.png" alt="support-hotfix" title>
                </div>
                <div class="image-caption">support-hotfix</div>
            </figure>
<h4 id="多版本的release"><a href="#多版本的release" class="headerlink" title="多版本的release"></a>多版本的release</h4><blockquote>
<p>多版本的<code>git flow</code>的<code>release</code>流程只是把master替换为需要维护的分支。</p>
</blockquote>
<figure class="image-bubble">
                <div class="img-lightbox">
                    <div class="overlay"></div>
                    <img src="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521111047-support-minor.png" alt title>
                </div>
                <div class="image-caption"></div>
            </figure>
<h2 id="git-flow工具的使用"><a href="#git-flow工具的使用" class="headerlink" title="git flow工具的使用"></a><code>git flow</code>工具的使用</h2><blockquote>
<p>windows和mac建议使用<code>sourcetree</code>客户端，内置了<code>git flow</code>流程，具体的使用方法，请自行搜索.</p>
<p>当然windows下的git for windows(git bash中)也内置了gitflow-scripts，请参考<a href="https://github.com/petervanderdoes/git-flow-completion" target="_blank" rel="noopener">升级版git-flow-completion</a>完成自动补全功能</p>
<p>如果使用linux，内置了gitflow-scripts（不知道是那个版本），很不负责任的建议使用<a href="https://github.com/petervanderdoes/gitflow-avh" target="_blank" rel="noopener">升级版gitflow-avh</a>.</p>
<p>关于使用git flow工具使用可以参考<a href="http://www.cnblogs.com/cnblogsfans/p/5075073.html" target="_blank" rel="noopener">如何正确使用Git Flow</a>这篇博客文章</p>
</blockquote>
<p><img src="https://raw.githubusercontent.com/betgar/betgar.github.io/master/img/picgo/20190521140451-sourcetree-git-flow.jpg" alt="sourcetree-git-flow"></p>
<blockquote>
<p>上图是sourcetree中git flow的菜单</p>
</blockquote>
<h2 id="git-flow和standard-version搭配使用"><a href="#git-flow和standard-version搭配使用" class="headerlink" title="git flow和standard-version搭配使用"></a><code>git flow</code>和<code>standard-version</code>搭配使用</h2><blockquote>
<p>请务必在熟悉<code>git flow</code>的基础上集成使用<code>standard-version</code>，因为两个工具的使用不当，会造成冲突。</p>
</blockquote>
<h3 id="git-flow流程中standard-version使用"><a href="#git-flow流程中standard-version使用" class="headerlink" title="git flow流程中standard-version使用"></a><code>git flow</code>流程中<code>standard-version</code>使用</h3><blockquote>
<p><code>standard-version</code>的作用就是生成<code>changelog</code>更新<code>package.json</code>和<code>package.lock.json</code>中的<code>version</code>字段。所以它在<code>git flow</code>中使用受<code>git flow</code>的流程限制。<br>目前我的经验是只能在<code>git flow</code>的<code>release/*</code>和<code>hotfix/*</code>分支中使用。<br>因为只有这两个分支涉及到发版流程，而<code>changelog</code>只有在发版时刻才生成。</p>
</blockquote>
<h3 id="git-flow和standard-version冲突的tag功能"><a href="#git-flow和standard-version冲突的tag功能" class="headerlink" title="git flow和standard-version冲突的tag功能"></a><code>git flow</code>和<code>standard-version</code>冲突的tag功能</h3><blockquote>
<p><code>git flow</code>和<code>standard-version</code>在使用的过程中，都有自动打<code>tag</code>的功能，但是两者都支持跳过<code>tag</code>阶段，所以这也是这两个工具冲突的地方，建议从两者中<strong>选取其一</strong>。</p>
<p><strong><em>强烈推荐 standard-version 自动 tag，不推荐使用git flow的tag功能</em></strong></p>
<p><strong>使用<code>git flow</code>自动tag必须保证tag格式<code>standard-version</code>能够识别，<code>standard-version</code>使用<a href="https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/git-semver-tags" target="_blank" rel="noopener">git-semver-tags</a>解析tag，参考<a href="https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/git-semver-tags/test.js" target="_blank" rel="noopener">git-semver-tags支持的格式</a></strong></p>
<p>如果standard-version识别tag出现遗漏，会造成生成的<code>changelog</code>内容重复。standard-version默认的tag前缀是<code>v</code>，可以自定义。</p>
</blockquote>
<ul>
<li><p><code>standard-version</code>跳过<code>tag</code>方法</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 方法一： package.json添加配置</span></span><br><span class="line">&#123;</span><br><span class="line">    <span class="string">"standard-version"</span>: &#123;</span><br><span class="line">        <span class="string">"skip"</span>: &#123;</span><br><span class="line">            <span class="string">"tag"</span>: <span class="literal">true</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 方法二：命令行中添加参数</span></span><br><span class="line">standard-version -r minor --skip.tag</span><br></pre></td></tr></table></figure>
</li>
<li><p><code>git flow</code>跳过<code>tag</code>的方法</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 跳过tag，并且可以自定义commit message(为了让commit message符合约定提交的格式规范)</span></span><br><span class="line">git flow release finish v0.2.0 -n -m <span class="string">"chore(release): 0.2.0"</span></span><br></pre></td></tr></table></figure>
</li>
</ul>
<h3 id="standard-version运行时机"><a href="#standard-version运行时机" class="headerlink" title="standard-version运行时机"></a><code>standard-version</code>运行时机</h3><ol>
<li>release 分支流程中运行</li>
</ol>
<blockquote>
<p><code>git flow</code>在<code>release finish</code>阶段是把<code>release/*</code>分支合并到<code>master</code>和<code>develop</code>，所以<code>standard-version</code>就是要在<code>finish</code>结束之前<strong>运行</strong>生成<code>changelog</code>.</p>
</blockquote>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 1. 模拟一个release流程</span></span><br><span class="line">git flow release start v0.2.0</span><br><span class="line"></span><br><span class="line"><span class="comment"># 2. 做一些修改或者commit</span></span><br><span class="line">git commit -m <span class="string">'fix(src): 修复问题'</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 3. （可选）如果需要在release/* 分支生成beta测试阶段的changelog</span></span><br><span class="line">npx standard-version -p beta</span><br><span class="line"></span><br><span class="line"><span class="comment"># 4. release finish 之前</span></span><br><span class="line"><span class="comment"># 强烈推荐 standard-version 自动tag，不推荐使用git flow的tag功能</span></span><br><span class="line">npx standard-version -r v0.2.0</span><br><span class="line"></span><br><span class="line"><span class="comment"># 5. 正式发布release，自定义commit message为了符合约定式提交的格式</span></span><br><span class="line">git flow release finish v0.2.0 -m <span class="string">"chore(release): 0.2.0"</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 如果你使用了standard-version的tag功能，git flow应该跳过tag</span></span><br><span class="line"><span class="comment"># git flow release finish v0.2.0 -n -m "chore(release): 0.2.0"</span></span><br></pre></td></tr></table></figure>
<ol start="2">
<li>hotfix分支流程中运行</li>
</ol>
<blockquote>
<p><code>hotfix finish</code>阶段和<code>release</code>非常像是把<code>hotfix/*</code>分支合并到<code>master</code>和<code>develop</code>，<strong>但是是否在<code>hotfix</code>分支生成<code>changelog</code>还需要自行决定（<u><em>有冲突的风险</em></u>）</strong></p>
</blockquote>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 1. 模拟一个hotfix流程</span></span><br><span class="line">git flow hotfix start v0.2.1</span><br><span class="line"></span><br><span class="line"><span class="comment"># 2. 做一些修改或者commit</span></span><br><span class="line">git commit -m <span class="string">'fix(src): 修复问题'</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 3. hotfix finish 之前</span></span><br><span class="line"><span class="comment"># 强烈推荐 standard-version 自动tag，不推荐使用git flow的tag功能</span></span><br><span class="line">npx standard-version -r v0.2.1 </span><br><span class="line"><span class="comment"># patch版本号可以使用 patch 替代</span></span><br><span class="line"><span class="comment"># npx standard-version -r patch</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 正式发布hotfix，自定义commit message为了符合约定式提交的格式</span></span><br><span class="line">git flow hotfix finish v0.2.1 -m <span class="string">"chore(release): 0.2.1"</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 如果你使用了standard-version的tag功能，git flow应该跳过tag</span></span><br><span class="line"><span class="comment"># git flow hotfix finish v0.2.0 -n -m "chore(release): 0.2.1"</span></span><br></pre></td></tr></table></figure>
<h3 id="standard-version在git-flow不同流程阶段注意的问题"><a href="#standard-version在git-flow不同流程阶段注意的问题" class="headerlink" title="standard-version在git flow不同流程阶段注意的问题"></a><code>standard-version</code>在<code>git flow</code>不同流程阶段注意的问题</h3><ol>
<li><p><code>standard-version</code>在<code>release</code>流程中注意事项：</p>
<ul>
<li><p>release中生成beta版本的<code>changelog</code></p>
<blockquote>
<p>前置条件：</p>
<ul>
<li>release 在hotfix之前创建</li>
<li>hotfix中生成changelog</li>
<li>release中生成beta版的changelog</li>
</ul>
<p>release分支的创建时机很重要，<code>git flow</code>流程中release在<code>hotfix</code>之后创建</p>
<p>如果创建release分支<strong>之后</strong>，出现并修复hotfix并且在hotfix生成changelog，<code>hotfix finish</code>之后<code>release finish</code>就会造成release合并到master和develop时出现<strong>冲突</strong>.</p>
<p>解决方案：</p>
<p>   release 分支包含<code>hotfix</code>内容（release 分支在hotfix之后创建，或者hotfix提取成patch，在release分支上apply）（<strong>git flow流程中hotfix是包含在next release中的</strong>）</p>
<ul>
<li>如果有更好的方法请告诉我 ~):</li>
</ul>
</blockquote>
</li>
</ul>
</li>
<li><p><code>standard-version</code>在<code>hotfix</code>流程中注意事项：</p>
<ul>
<li><p><code>hotfix</code>中生成changelog</p>
<blockquote>
<ul>
<li>release分支在<code>hotfix finish</code> <strong><em>之前建立</em></strong>，会出现在release分支一样的问题</li>
</ul>
</blockquote>
</li>
<li><p><code>hotfix</code>分支不生成changelog</p>
<blockquote>
<ul>
<li>release分支在hotfix finish <strong><em>之前建立</em></strong>，会造成<code>hotfix</code>修复的的日志无法出现在changelog中</li>
</ul>
</blockquote>
</li>
</ul>
<blockquote>
<p>解决方法：</p>
<p>release 分支包含<code>hotfix</code>内容（release 分支在hotfix之后创建，或者hotfix提取成patch，在release分支上apply）</p>
</blockquote>
</li>
<li><p><code>standard-version</code>不带参数使用</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 如果直接在分支上，使用</span></span><br><span class="line">standard-version</span><br></pre></td></tr></table></figure>
<p>如果不指定参数直接使用<code>standard-version</code>命令，<code>standard-version</code>会自动分析<code>commit message</code>类型，如果包含patch就累加patch，有feat就自动累加minor，有<code>break change</code>就自动生成 major版本号，<strong>风险较大，建议指定参数</strong>。</p>
</li>
</ol>
<h2 id="建议"><a href="#建议" class="headerlink" title="建议"></a>建议</h2><blockquote>
<p>工具和流程模型都是根据使用场景，灵活多变的，所以不要局限于工具和流程模型，实践出适合自己的流程模型才是最重要的。</p>
</blockquote>
<h2 id="参考"><a href="#参考" class="headerlink" title="参考"></a>参考</h2><p><a href="https://nvie.com/posts/a-successful-git-branching-model/" target="_blank" rel="noopener">a-successful-git-branching-model</a></p>
<p><a href="https://github.com/nvie/gitflow" target="_blank" rel="noopener">原版git flow scripts弃坑状态不建议使用</a></p>
<p><a href="https://github.com/bobthecow/git-flow-completion" target="_blank" rel="noopener">原版git-flow-completion</a></p>
<p><a href="https://github.com/petervanderdoes/gitflow-avh" target="_blank" rel="noopener">升级版gitflow-avh</a></p>
<p><a href="https://github.com/petervanderdoes/git-flow-completion" target="_blank" rel="noopener">升级版git-flow-completion</a></p>
<p><a href="https://www.conventionalcommits.org/" target="_blank" rel="noopener">约定式提交规范</a></p>
<p><a href="https://danielkummer.github.io/git-flow-cheatsheet/index.zh_CN.html" target="_blank" rel="noopener">git-flow 备忘清单</a></p>
<p><a href="https://github.com/devdigital/git-flow-standard-version" target="_blank" rel="noopener">git-flow-standard-version</a></p>
<p><a href="http://digital-cult.com/releasing-js-library-github-git-flow-conventional-commits/" target="_blank" rel="noopener">git-flow-conventional-commits</a></p>
<p><a href="http://www.cnblogs.com/cnblogsfans/p/5075073.html" target="_blank" rel="noopener">如何正确使用Git Flow</a></p>
<p><a href="https://segmentfault.com/q/1010000000430041" target="_blank" rel="noopener">git rebase保持代码树整洁</a></p>
<p><a href="http://blog.jobbole.com/76847/" target="_blank" rel="noopener">集中式工作流</a></p>
<p><a href="http://blog.jobbole.com/76857/" target="_blank" rel="noopener">功能分支工作流</a></p>
<p><a href="http://blog.jobbole.com/76867/" target="_blank" rel="noopener">Gitflow工作流</a></p>
<p><a href="http://blog.jobbole.com/76861/" target="_blank" rel="noopener">Forking工作流</a></p>
<p><a href="https://www.atlassian.com/git/tutorials/comparing-workflows" target="_blank" rel="noopener">comparing-workflows</a><br><a href="https://gitversion.readthedocs.io/en/latest/git-branching-strategies/gitflow-examples/" target="_blank" rel="noopener">gitflow-examples</a></p>

        </div>

        <blockquote class="post-copyright">
    
    <div class="content">
        
<span class="post-time">
    最后更新时间：<time datetime="2019-06-14T08:29:44.250Z" itemprop="dateUpdated">2019-06-14 16:29:44</time>
</span><br>


        
        原文链接：<a href="/2019/05/21/frontend-little-tangle-integrate-git-flow-and-standard-version/" target="_blank" rel="external">https://betgar.github.io/2019/05/21/frontend-little-tangle-integrate-git-flow-and-standard-version/</a>
        
    </div>
    
    <footer>
        <a href="https://betgar.github.io">
            <img src="/img/avatar.jpg" alt="俊男">
            俊男
        </a>
    </footer>
</blockquote>

        


        <div class="post-footer">
            
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/fe/">fe</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/gitflow/">gitflow</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/standard-version/">standard-version</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=https://betgar.github.io/2019/05/21/frontend-little-tangle-integrate-git-flow-and-standard-version/&title=《前端小纠结--集成gitflow和standard-version使用》 — 个人博客&pic=https://betgar.github.io/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=https://betgar.github.io/2019/05/21/frontend-little-tangle-integrate-git-flow-and-standard-version/&title=《前端小纠结--集成gitflow和standard-version使用》 — 个人博客&source=各种技术加身的coder" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https://betgar.github.io/2019/05/21/frontend-little-tangle-integrate-git-flow-and-standard-version/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《前端小纠结--集成gitflow和standard-version使用》 — 个人博客&url=https://betgar.github.io/2019/05/21/frontend-little-tangle-integrate-git-flow-and-standard-version/&via=https://betgar.github.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=https://betgar.github.io/2019/05/21/frontend-little-tangle-integrate-git-flow-and-standard-version/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/2019/06/06/nvs-usage-considerations/" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> Prev</div>
        <h4 class="title">nvs使用的注意事项</h4>
      </a>
    </div>
  

  
    <div class="waves-block waves-effect next">
      <a href="/2019/05/20/frontend-little-tangle-conventional-commit-and-generate-changelog/" id="post-next" class="post-nav-link">
        <div class="tips">Next <i class="icon icon-angle-right icon-lg icon-pl"></i></div>
        <h4 class="title">前端小纠结--约定式提交和自动生成changelog</h4>
      </a>
    </div>
  
</nav>



    











    <!-- Valine Comments -->
    <div class="comments vcomment" id="comments"></div>
    <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
    <script src="//unpkg.com/valine@latest/dist/Valine.min.js"></script>
    <!-- Valine Comments script -->
    <script>
        var GUEST_INFO = ['nick','mail','link'];
        var guest_info = 'nick,mail,link'.split(',').filter(function(item){
          return GUEST_INFO.indexOf(item) > -1
        });
        new Valine({
            el: '#comments',
            notify: 'false' == 'true',
            verify: 'false' == 'true',
            appId: "kiGWA9mdoVtQlfGYA5uDBNX7-gzGzoHsz",
            appKey: "dHCOdD0oEIjJd0cJoAHHN0y3",
            avatar: "mm",
            placeholder: "Just comment it",
            guest_info: guest_info.length == 0 ? GUEST_INFO : guest_info,
            pageSize: "10"
        })
    </script>
    <!-- Valine Comments end -->







</article>



</div>

        <footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style="display:none">
        站点总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style="display:none">
        站点总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <p>
            
                <span><a href="/atom.xml" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
            
            <span>博客内容遵循 <a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">知识共享 署名 - 非商业性 - 相同方式共享 4.0 国际协议</a></span>
        </p>
    </div>
    <div class="bottom">
        <p><span>俊男 &copy; 2017 - 2020</span>
            <span>
                
                Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://github.com/yscoder/hexo-theme-indigo" target="_blank">indigo</a>
            </span>
        </p>
    </div>
</footer>

    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=https://betgar.github.io/2019/05/21/frontend-little-tangle-integrate-git-flow-and-standard-version/&title=《前端小纠结--集成gitflow和standard-version使用》 — 个人博客&pic=https://betgar.github.io/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=https://betgar.github.io/2019/05/21/frontend-little-tangle-integrate-git-flow-and-standard-version/&title=《前端小纠结--集成gitflow和standard-version使用》 — 个人博客&source=各种技术加身的coder" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https://betgar.github.io/2019/05/21/frontend-little-tangle-integrate-git-flow-and-standard-version/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《前端小纠结--集成gitflow和standard-version使用》 — 个人博客&url=https://betgar.github.io/2019/05/21/frontend-little-tangle-integrate-git-flow-and-standard-version/&via=https://betgar.github.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=https://betgar.github.io/2019/05/21/frontend-little-tangle-integrate-git-flow-and-standard-version/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/', SHARE: true, REWARD: false };


</script>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/main.min.js"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/search.min.js" async></script>






<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>





</body>
</html>
